﻿using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    /// <summary>
    /// 上下文简单工厂
    /// <remarks>
    /// 创建：2016.09.03
    /// </remarks>
    /// </summary>
    public class ContextFactory
    {

        /// <summary>
        /// 获取当前数据上下文
        /// </summary>
        /// <returns></returns>
        public static DBContainer GetCurrentContext()
        {
            DBContainer _Context = CallContext.GetData("DBContainer") as DBContainer;
            if (_Context == null)
            {
                _Context = new DBContainer();
                CallContext.SetData("DBContainer", _Context);
            }
            return _Context;
        }
    }
}
